package edu.wtbu.cs.androiddemo.activity.list;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

import edu.wtbu.cs.androiddemo.R;
import edu.wtbu.cs.androiddemo.adapter.Good;
import edu.wtbu.cs.androiddemo.adapter.goodsListAdapter;

public class GoodsListActivity extends AppCompatActivity {
    private RecyclerView recyclerView;
    private LinearLayoutManager linearLayoutManager;
    private List<Good> goodList = new ArrayList<Good>();
    private int[] pictrue = {R.drawable.a000, R.drawable.a001, R.drawable.a002, R.drawable.a003,
            R.drawable.a004, R.drawable.a005, R.drawable.a006, R.drawable.a007, R.drawable.a008,
            R.drawable.a009};
    private String[] title = {"2019秋装新款白色纯棉长袖t恤女装宽松春秋打底衫体恤大码上衣", "2019初秋新款潮韩版洋气女装宽松秋季短款衬衫女秋装方领长袖上衣",
            "纯棉长袖T恤女上衣2019新款竹节棉宽松秋衣女装薄款初秋打底衫潮", "半高领打底衫女装秋冬薄款洋气莫代尔堆堆领长袖t恤内搭针织上衣",
            "女装2019新款潮超火cec短袖女春夏季港味宽松百搭上衣T恤ins洋气", "夏大大胖mm韩版宽松秋装新款女装大码2019牛仔套装外套减龄连衣裙",
            "大姗姗家瘦瘦裤胖mm韩版大码女装秋季百搭外穿打底裤网红款小脚裤", "中国大陆','夏装紧身纯白色T恤女短袖修身女装女士纯棉2019新款上衣潮打底衫",
            "纯棉长袖T恤女上衣2019新款竹节棉宽松秋衣女装薄款初秋打底衫潮", "纯棉红色v领T恤女短袖修身夏女装2019新款潮体恤紧身上衣黑色短款",};
    private String[] location = {"云南 昆明", "广东 广州", "江西 南昌", "广东 汕头", "浙江 金华", "广东 广州", "江苏 淮安",
            "江苏 苏州", "广东 深圳", "安徽 芜湖"};
    private String[] shop = {"lovtis兰蒂斯旗舰店", "lovtis兰蒂斯旗舰店", "lovtis兰蒂斯旗舰店", "lovtis兰蒂斯旗舰店",
            "旗舰店", "旗舰店", "旗舰店", "旗舰店", "旗舰店", "旗舰店"};
    private String[] number = {"87816", "37384", "62165", "43221", "4561", "43211", "3011",
            "764", "7656", "4567"};
    private String[] prices = {"39.9", "29.87", "29", "56", "20", "138", "97", "15", "78", "30"};


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_goods_list);
        initView();

    }

    private void initView() {

        for (int i = 0; i < 10; i++) {
            Good good = new Good();
            good.setImage(pictrue[i]);
            good.setName(title[i]);
            good.setProductLocation(location[i]);
            good.setShopName(shop[i]);
            good.setPrice(Double.valueOf(prices[i]));
            good.setVolume(number[i]);
            goodList.add(good);
        }
        recyclerView = (RecyclerView) findViewById(R.id.recycle_Viewes);
        linearLayoutManager = new LinearLayoutManager(this);
        //   LinearLayoutManager linearLayoutManager = new LinearLayoutManager(RecyclerViewSampleActivity.this);

        recyclerView.setLayoutManager(linearLayoutManager);
        //为recycleViews设定动画
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        //为recycleViews添加分割线
        recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration
                .VERTICAL));
        recyclerView.setAdapter(new goodsListAdapter(this, goodList));
    }
}